package com.yorge.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {
    private int code;
    private String message;
    private T data;

    public CommonResult(int code, String message) {
        this(code, message, null);
    }
    public static <T> CommonResult<T> success() {
        return new CommonResult<T>(200, "success");
    }
    public static <T> CommonResult<T> success(String message) {
        return new CommonResult<T>(200, message);
    }
    public static <T> CommonResult<T> success(String message, T data) {
        return new CommonResult<T>(200, message, data);
    }
    public static <T> CommonResult<T> error(String message) {
        return new CommonResult<T>(500, message);
    }
}
